home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / MPW / MPW re2c 1.1 / substr.cc < prev    next >
Encoding:
Text File  |  1995-06-01  |  579 b   |  34 lines  |  [TEXT/MPS ]

  1. // $Log: substr.cc,v $
  2. //Revision 1.1  1994/04/08  15:27:59  peter
  3. //Initial revision
  4. //
  5.  
  6. #include <string.h>
  7. #include "substr.h"
  8.  
  9. void SubStr::out(ostream& o) const {
  10.     o.write(str, len);
  11. }
  12.  
  13. bool operator==(const SubStr s1, const SubStr s2){
  14.     return (bool) (s1.len == s2.len && memcmp(s1.str, s2.str, s1.len) == 0);
  15. }
  16.  
  17. Str::Str(const SubStr& s) : SubStr(new char[s.len], s.len) {
  18.     memcpy(str, s.str, s.len);
  19. }
  20.  
  21. Str::Str(Str& s) : SubStr(s.str, s.len) {
  22.     s.str = NULL;
  23.     s.len = 0;
  24. }
  25.  
  26. Str::Str() : SubStr((char*) NULL, 0) {
  27.     ;
  28. }
  29.  
  30.  
  31. Str::~Str() {
  32.     delete str;
  33. }
  34.